import { _decorator, Component, Node, resources, SpriteFrame, Sprite } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('enemy')
export class enemy extends Component {
	@property
	speed:number = 70
    start() {

    }
    update(deltaTime: number) {
			this.node?.setPosition(
				this.node.getPosition().x,
				this.node.getPosition().y -this.speed*deltaTime
			)
		if (this.node?.getPosition().y<-450){
			this.node.destroy()
		}
    }
	die() {
		this.speed =0
		resources.load('enemy0_die/spriteFrame',SpriteFrame, (err,data)=> {
			this.node.getComponent(Sprite).spriteFrame = data
		})
		setTimeout(()=>{
			this.node?.destroy();
		},300)
			
	}
}

